transport: Abort canceled dial attempts for TCP, WebSocket and Quic #255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
TransportManager
initiates a dialing process on multiple addresses and multiple transports (ie TCP WebSocket).The first established connection is reported back from the Transport layer to the
TransportManger
.Then, the
Transport Manager
cancels all ongoing dialing attempts on the remaining layers.Previously, cancelling implies storing a
ConnectionID
to a HashSet.This has the downside that all ongoing dial attempts are polled to completion.
In this PR, the futures that establish socket connections are now aborted directly.
Example
T0. Manager initiates dialing on A, B, C for TCP and D, E, F on WebSocket
T1. Established socket connection on address A from TCP (B and C are dropped)
T2. Manager cancels D, E, F from WebSocket
Before
T2 implies adding a connectionID to a hashset:
litep2p/src/transport/tcp/mod.rs
Lines 518 to 519 in 14dc4cc
The worst case scenario:
The best case scenario:
litep2p/src/transport/tcp/mod.rs
Lines 536 to 542 in d50ec10
After
The future that handles dialing is abortable. This way, we don't have to wait for (worst case) all addresses to fail to connect, or (best case) one address to connect.